#ifndef __ANALYSISKLV_H
#define __ANALYSISKLV_H
#include <map>
#include <string>
using std::map;
using std::string;
class AnalysisKLV
{
    typedef std::string (*pFunc)(const unsigned char *, const int);
private:
    typedef struct tagKLV
    {
        std::string fun;
        std::string msg;
        tagKLV(	std::string _fun,std::string _msg)
        {
            this->fun = _fun;
            this->msg = _msg;
        }
    }tagKLV;
private:
    /* data */
    std::map<std::string,pFunc> m_funtype;
    std::map<int,tagKLV> m_KlvType;
public:
    AnalysisKLV(/* args */);
    ~AnalysisKLV();
public:
    int         Analysis(char* pInputBuf);

private:
    static std::string ToHexString(const unsigned char* pData,size_t nSize);
    //  去char*空格
    void        TrimStr(const char *oriStr, char *resStr);
    //  
    int         ascii2hex(char ch);
    //  16进制string 转 16进制 
    int         str2hex(char* szStr, int szlen, char* szHex, int hexlen);
public:
    // 回调函数        
    // 按 char解析
    static std::string funNCHAR(const unsigned char * uBuf, const int iLen);
    // 按 16进制解析
    static std::string funHEX(const unsigned char * uBuf,   const int iLen);
    // 按 整数解析
    static std::string funNUM(const unsigned char * uBuf,   const int iLen);

};




#endif